/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * fErrores.java
 *
 * Created on 02/06/2011, 11:39:01
 */
package cskernelclient;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import org.jdesktop.application.Action;

/**
 *
 * @author jalvarez
 */
public class fErrores extends javax.swing.JDialog {

    /** Creates new form fErrores */
    public fErrores(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setLayout(null);
        this.setSize(535, 125);
        this.setLocationRelativeTo(null);
        this.cmdOk.setText("Aceptar");
        this.cmdDetails.setText("Detalles");
        this.cmdDetails.setLocation(535-this.cmdDetails.getSize().width-30, this.cmdDetails.getLocation().y);
        this.cmdOk.setLocation(this.cmdDetails.getLocation().x, this.cmdOk.getLocation().y);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        cmdOk = new javax.swing.JButton();
        cmdDetails = new javax.swing.JButton();
        lbImage = new javax.swing.JLabel();
        lbDescrip = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        txDetails = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(fErrores.class, this);
        cmdOk.setAction(actionMap.get("cmdOkClick")); // NOI18N
        cmdOk.setText("Aceptar");
        cmdOk.setName("cmdOk"); // NOI18N

        cmdDetails.setAction(actionMap.get("cmdDetailsClick")); // NOI18N
        cmdDetails.setText("Detalles");
        cmdDetails.setName("cmdDetails"); // NOI18N

        lbImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cskernelclient/resources/Warning-icon.png"))); // NOI18N
        lbImage.setName("lbImage"); // NOI18N

        lbDescrip.setText("Ha ocurrido un error en el sistema.");
        lbDescrip.setName("lbDescrip"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        txDetails.setColumns(20);
        txDetails.setRows(5);
        txDetails.setName("txDetails"); // NOI18N
        jScrollPane1.setViewportView(txDetails);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(lbImage)
                        .addGap(18, 18, 18)
                        .addComponent(lbDescrip)
                        .addGap(181, 181, 181)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(cmdOk, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cmdDetails, javax.swing.GroupLayout.Alignment.LEADING)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbImage)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(lbDescrip))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(cmdOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cmdDetails)))
                .addGap(18, 18, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                try {
                    // Set cross-platform Java L&F (also called "Metal")
                    UIManager.setLookAndFeel(
                        UIManager.getSystemLookAndFeelClassName());
                } 
                catch (UnsupportedLookAndFeelException e) {
                   // handle exception
                }
                catch (ClassNotFoundException e) {
                   // handle exception
                }
                catch (InstantiationException e) {
                   // handle exception
                }
                catch (IllegalAccessException e) {
                   // handle exception
                }

                fErrores dialog = new fErrores(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    @Action
    public void cmdOkClick() {
        this.setVisible(false);
    }

    @Action
    public void cmdDetailsClick() {
        if (this.cmdDetails.getText().equals("Detalles")) {
            this.cmdDetails.setText("Ocultar");
            this.setSize(535, 250);
        }
        else {
            this.cmdDetails.setText("Detalles");
            this.setSize(535, 125);
        }
    }
    
    public void addDetail(String text) {
        this.txDetails.append(text + "\\n");
    }
    
    public void setCaption(String caption) {
        this.setTitle(caption);
    }
    
    public void setWarning() {
        // esta hecho por diseño
    }
    
    public void setFatal() {
        lbImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cskernelclient/resources/Status-dialog-error-icon.png"))); // NOI18N
    }
    
    public void setInformation() {
        lbImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/cskernelclient/resources/Status-dialog-information-icon.png"))); // NOI18N
    }
    
    public void setDescrip(String value) {
        lbDescrip.setText(value);
    }
    
    public String getDetail() {
        return txDetails.getText();
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cmdDetails;
    private javax.swing.JButton cmdOk;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lbDescrip;
    private javax.swing.JLabel lbImage;
    private javax.swing.JTextArea txDetails;
    // End of variables declaration//GEN-END:variables
}
